home *** CD-ROM | disk | FTP | other *** search
- 10 poke 53281,1 : poke 53280,1 : print chr$(144)
- 20 gosub 4000
- 30 x=0
- 40 read a : if a=255 then 60
- 50 read b$ : read c : x=x+1 : goto 40
- 60 dim dec%(x),opcode$(x),byte%(x)
- 70 dim ad(255),s$(255),c$(255)
- 80 er=x-1
- 90 restore
- 100 for i=0 to x-1 : read dec%(i) : read opcode$(i) : read byte%(i)
- 110 next i
- 120 print chr$(146);chr$(147)
- 130 print "adrs"; tab(10);"opcode";tab(25);"operand"
- 140 for x=1 to 40 : print chr$(114); : next
- 150 print
- 160 rem ****************************
- 170 rem set address and input opcode
- 180 rem ****************************
- 190 sa=0 : print "press <return> to default to 49152"
- 200 n=0
- 210 input "starting addr";sa : if sa=0 then sa=49152
- 220 ba=sa
- 230 print sa;tab(10);
- 240 input oc$ : if oc$="q" then 760
- 250 c=0
- 260 if oc$=opcode$(c) then d%=dec%(c) : b%=byte%(c) : goto 290
- 270 c=c+1 : if c>er then print tab(10);chr$(18);"error";chr$(146) : goto 230
- 280 goto 260
- 290 if b%=1 then poke sa,d% : sa=sa+1
- 300 if b%=1 then s$(n)=oc$ : ad(n)=sa-1 : n=n+1 : goto 230
- 310 rem *************
- 320 rem enter operand
- 330 rem *************
- 340 print tab(25); : print chr$(145); : input opr$
- 350 ad(n)=sa : s$(n)=oc$ : c$(n)=opr$ : n=n+1
- 360 if left$(opr$,1)<>"$" then oper=val(opr$)
- 370 if left$(opr$,1)="$" then gosub 490
- 380 if oper >65535 then gosub 630 : oper=0: goto 340
- 390 if oc$="bne" or oc$="beq" then gosub 700
- 400 if oper>255 and b% <3 then gosub 560: oper=0 : goto 340
- 410 if oper > 255 then gosub 640
- 420 rem ************
- 430 rem compile code
- 440 rem ************
- 450 if b%=2 then poke sa,d% : sa=sa + 1
- 460 if b%=2 then poke sa,oper : sa=sa+1 : oper=0 : goto 230
- 470 poke sa,d%: sa=sa+1
- 480 poke sa,lb : sa=sa+1 : poke sa,hb : sa=sa+1 : oper=0 : goto 230
- 490 rem **********************
- 500 rem convert hex to decimal
- 510 rem **********************
- 520 h$=mid$(oper$,2)
- 530 for l=1 to len(h$) : hd=asc(mid$(h$,l,1))
- 540 oper=oper*16+hd-48+((hd>57)*7)
- 550 next l : return
- 560 rem **********
- 570 rem error trap
- 580 rem **********
- 590 print chr$(18);"error-must be less than 256"
- 600 for w=1 to 400 : next w : printchr$(146); : print chr$(145);
- 610 for x=1 to 27 : printchr$(32); : next
- 620 print chr$(157);chr$(157);chr$(145) :return
- 630 print chr$(18);"value over 65535 ($ffff)";chr$(146) : return
- 640 rem ************************
- 650 rem convert to 2 byte number
- 660 rem ************************
- 670 lb=oper-int(oper/256)*256
- 680 hb=int(oper/256)
- 690 return
- 700 rem *************
- 710 rem branch offset
- 720 rem *************
- 730 if sa > oper then oper= 254-(sa-oper)
- 740 if sa < oper then oper= (oper-sa)-2
- 750 return
- 760 rem **************
- 770 rem ending routine
- 780 rem **************
- 790 nb = sa-ba
- 800 print chr$(147)
- 810 for x=1 to 5 : print : next
- 820 input"save program(y/n)";an$
- 830 if an$="y" then 890
- 840 print : print : print "program is";nb;"bytes long"
- 850 print "to execute 'sys'";ba : print
- 860 input "(b)egin again or (e)nd";de$
- 870 if de$="b" then 120
- 880 print : print"end" : end
- 890 print chr$(147) : for x=1 to 5 : print : next
- 900 lb=ba-int(ba/256)*256 : hb=int(ba/256)
- 910 input "enter file name";nw$:nf$=nw$:nf$="0:"+nf$+str$(ba)+",p,w"
- 920 open2,8,2,nf$
- 930 print#2,chr$(lb)+chr$(hb);
- 940 for x=ba to sa-1: oc=peek(x)
- 950 print#2,chr$(oc);
- 960 next x
- 970 close2
- 980 nf$=""
- 990 nf$="0:" + nw$+",s,w"
- 1000 open 9,8,9,nf$
- 1010 for v=0 to n-1
- 1020 print#9,ad(v),s$(v),c$(v)
- 1030 next v
- 1040 close9
- 1050 goto 840
- 1060 rem ***********
- 1070 rem opcode data
- 1080 rem ***********
- 1090 data 24,clc,1
- 1100 data 32,jsr,3
- 1110 data 56,sec,1
- 1120 data 73,eor#,2
- 1130 data 76,jmp,3
- 1140 data 77,eor,3
- 1150 data 96,rts,1
- 1160 data 105,adc#,2
- 1170 data 108,(jmp),3
- 1180 data 109,adc,3
- 1190 data 121,adc-y,3
- 1200 data 125,adc-x,3
- 1210 data 129,(sta-x),2
- 1220 data 133,sta-z,2
- 1230 data 134,stx-z,2
- 1240 data 136,dey,1
- 1250 data 138,txa,1
- 1260 data 140,sty,3
- 1270 data 141,sta,3
- 1280 data 142,stx,3
- 1290 data 145,(sta-y),2
- 1300 data 148,sty-x,2
- 1310 data 152,tya,1
- 1320 data 157,sta-x,3
- 1330 data 153,sta-y,3
- 1340 data 154,txs,1
- 1350 data 160,ldy#,2
- 1360 data 161,(lda-x),2
- 1370 data 162,ldx#,2
- 1380 data 164,ldy-z,2
- 1390 data 165,lda-z,2
- 1400 data 166,ldx-z,2
- 1410 data 168,tay,1
- 1420 data 169,lda#,2
- 1430 data 170,tax,1
- 1440 data 172,ldy,3
- 1450 data 173,lda,3
- 1460 data 174,ldx,3
- 1470 data 177,(lda-y),2
- 1480 data 185,lda-y,3
- 1490 data 186,tsx,1
- 1500 data 188,ldy-x,3
- 1510 data 189,lda-x,3
- 1520 data 190,ldx-y,3
- 1530 data 192,cpy#,2
- 1540 data 193,(cmp-x),2
- 1550 data 196,cpy-z,2
- 1560 data 197,cmp-z,2
- 1570 data 198,dec-z,2
- 1580 data 200,iny,1
- 1590 data 201,cmp#,2
- 1600 data 202,dex,1
- 1610 data 204,cpy,3
- 1620 data 205,cmp,3
- 1630 data 206,dec,3
- 1640 data 208,bne,2
- 1650 data 221,cmp-x,3
- 1660 data 222,dec-x,3
- 1670 data 224,cpx#,2
- 1680 data 230,inc-z,2
- 1690 data 232,inx,1
- 1700 data 233,sbc#,2
- 1710 data 234,nop,1
- 1720 data 236,cpx,3
- 1730 data 237,sbc,3
- 1740 data 238,inc,3
- 1750 data 240,beq,2
- 1760 data 249,sbc-y,3
- 1770 data 253,sbc-x,3
- 1780 data 254,inc-x,3
- 1790 rem ************************
- 1800 rem add additional data here
- 1810 rem ************************
- 1820 data 255
- 4000 rem ******
- 4010 rem header
- 4020 rem ******
- 4030 print chr$(147)
- 4040 ld$="loading array" : for x=1 to 10 : print : next : h=20-len(ld$)/2
- 4050 print tab(h);chr$(18);ld$
- 4060 return
-